package com.wx.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wx.pojo.Commodity;
import com.wx.pojo.vo.JsonResult;
import com.wx.service.CommodityService;

@RestController
@RequestMapping("/commo/")
public class CommodityController {

	@Autowired
	private CommodityService commodityService;
	
	@RequestMapping("addCommodity")
	public JsonResult addCommodity(Commodity commodity,String token) {
		commodityService.insertCommodity(commodity,token);
		return new JsonResult("add success");
	}
	
	@RequestMapping("findCommodity")
	public JsonResult findCommodity(String token) {
		return new JsonResult(commodityService.findCommodityByUserId(token));
	}
	
	@RequestMapping("updateCommodity")
	public JsonResult updateCommodity(Commodity commodity,String token) {
		commodityService.updateCommodityById(commodity,token);
		return new JsonResult("update ok");
	}
}
